exp = module.exports
dispatcher = require './dispatcher'

exp.chat = (session, msg, app, cb)->
	chatServers = app.getServersByType 'chat'

	if !chatServers || chatServers.length ==0
		cb new Error('can not find chat servers.')
		return

	res = dispatcher.dispatch(session.get('rid'), chatServers)
	cb null, res.id
